package com.syx.product.Controller;

import com.syx.product.Model.ProductInfo;
import com.syx.product.Service.ProductService;
import com.syx.product.api.ProductInterface;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
@RequestMapping("/product")
@RestController
public class ProductController implements ProductInterface {

    @Resource
    ProductService productService;
    @RequestMapping("/{productId}")
    public ProductInfo getProductInfo(@PathVariable("productId") Integer id){
        return productService.selectByProductById(id);
    }

    @RequestMapping("/p1")
    public String p1(Integer id){
        return "接收到参数 id"+id;

    }

    @RequestMapping("/p2")
    public String p2(@RequestParam("id") Integer id,@RequestParam("name") String name){
        return "接收到消息id为"+id+"接收到name+"+name;
    }


    @RequestMapping("/p3")
    public String p3(ProductInfo productInfo){
        return productInfo.toString();
    }


    @RequestMapping("/p4")
    public String p4(@RequestBody ProductInfo productInfo){
        return productInfo.toString();
    }

}
